package org.lgiavedoni.android.franq.core.prediction;

import java.util.TimerTask;

import org.lgiavedoni.android.franq.core.prediction.imp.PredictionEventDate;
import org.lgiavedoni.android.franq.service.communication.CommunicationService;

public class PredictionTimerTask extends TimerTask {

	private final PredictionEventDate prediction;

	public PredictionTimerTask(PredictionEventDate prediction) {
		super();
		this.prediction = prediction;
		// prediction.setTimerTask(this);
	}

	public PredictionEventDate getPrediction() {
		return prediction;
	}

	@Override
	public void run() {
		// check event occurrence
		if (!prediction.checkOccurrence()) {
			// show the predictionTimeOff for the message
			CommunicationService.inst.sendDefaultTextMessage((prediction.getEvent()).predictionTimeOff());
		} else {
			// The prediction was correct
			// prediction.getRule().addOccurrence();
			// PredictionDAO.inst.update(prediction);
		}
	}
}
